package com.crm.controller;

import com.crm.common.result.AjaxResult;
import com.crm.common.result.Result;
import com.crm.domain.Contract;
import com.crm.service.ContractService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/contract")
public class ContractController {

    @Autowired
    private ContractService contractService;

    // 新增合同
    @PostMapping
    public AjaxResult save(@RequestBody Contract contract) {
        contractService.saveContract(contract);
        return AjaxResult.success();
    }

    //根据id查询合同
    @GetMapping("/{id}")
    public AjaxResult getById(@PathVariable Long id) {
        log.info("根据id查询合同：{}",id);
        Contract contract = contractService.getById(id);
        return AjaxResult.success(contract);
    }



}
